package lxh.com.union.logic_business.ui.activity;

import android.widget.RadioGroup;

import butterknife.BindView;
import lxh.com.union.R;
import lxh.com.union.frame.mvp.FrameMvpActivity;
import lxh.com.union.logic_business.present.MainPresent;
import lxh.com.union.logic_business.ui.fragment.ClassifyFragment;
import lxh.com.union.logic_business.ui.fragment.ConmmunityFragment;
import lxh.com.union.logic_business.ui.fragment.HomePageFragment;
import lxh.com.union.logic_business.ui.fragment.MineFragment;
import lxh.com.union.logic_business.ui.fragment.ShoppingCarFragment;
import lxh.com.union.logic_business.ui.mvpview.IMainView;
import lxh.com.union.logic_business.util.FragmentHelper;

/**
 * Created by Administrator on 2017/11/27.
 */

public class MainActivity extends FrameMvpActivity<MainPresent> implements IMainView {
    @BindView(R.id.rg)
    RadioGroup mRg;

    private final String HOME_PAGE="homepage";
    private final String CLASSIFY="classify";
    private final String COMMUNITY="community";
    private final String SHOPPING_CAR="shoppingcar";
    private final String MINE="mine";
    @Override
    protected void initView() {
        mRg.setOnCheckedChangeListener((group, checkedId) -> {
            switch (checkedId){
                case R.id.rb_home:{
                    FragmentHelper.getInsctance(MainActivity.this).fragmentManager(R.id.fragment_container,new HomePageFragment(),HOME_PAGE);
                }break;
                case R.id.rb_classify:{
                    FragmentHelper.getInsctance(MainActivity.this).fragmentManager(R.id.fragment_container,new ClassifyFragment(),CLASSIFY);
                }break;
                case R.id.rb_conmunity:{
                    FragmentHelper.getInsctance(MainActivity.this).fragmentManager(R.id.fragment_container,new ConmmunityFragment(),COMMUNITY);
                }break;
                case R.id.rb_shopping_car:{
                    FragmentHelper.getInsctance(MainActivity.this).fragmentManager(R.id.fragment_container,new ShoppingCarFragment(),SHOPPING_CAR);
                }break;
                case R.id.rb_mine:{
                    FragmentHelper.getInsctance(MainActivity.this).fragmentManager(R.id.fragment_container,new MineFragment(),MINE);
                }break;
            }
        });
        mRg.getChildAt(0).performClick();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_main;
    }

    @Override
    protected MainPresent createPresent() {
        return new MainPresent();
    }

}
